﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using 开单.DB;
using 开单.Dao.基础;

namespace 开单.Frm.基础
{
    public partial class FrmXgmm : Form
    {
        YhxxDao yhxxDao = new YhxxDao();

        public FrmXgmm()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if(!(IsOkToModify())){return;}
            GlobalVar.yhxxEntity.yh_psw=TxtNewPsw2.Text;
            yhxxDao.UpdataYhxx(GlobalVar.yhxxEntity);
            MessageBox.Show("修改成功");
            this.Close();
        }

        private bool IsOkToModify()
        {
            if (TxtOldPsw.Text != GlobalVar.yhxxEntity.yh_psw) { MessageBox.Show("原密码输入错误,请重输"); IntityControl(); return false; }
            if (TxtNewPsw.Text != TxtNewPsw2.Text) { MessageBox.Show("密码不一致，请重输"); IntityControl(); return false; }
            return true;
        }

        private void IntityControl()
        {
            TxtOldPsw.Text = "";
            TxtNewPsw.Text = "";
            TxtNewPsw2.Text = "";
            TxtOldPsw.Focus();
        }
    }
}
